<template>
  <div class="mod-config">
    <basic-container>
      <!--新增跳转-->
      <div v-if="rwszbForm.enter==0||rwszbForm.enter==3|| rwszbForm.enter==6" >
        <div :height="searchheight">
            <span style="float:right;margin-top: -10px;cursor: pointer;"
                  @click="searchchangeadvanced">{{ searchadvanced ? "收起" : "展开" }}
            <i :class="searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"/> </span>
          <div v-show="searchadvanced">
            <div class="flex">
              <div class="mt20">
                <el-row>
                  <el-col :span="24">
                    <el-form :model="form" label-width="120px" label-position="right" ref="rwszbForm">
                      <el-col :span="12">
                        <el-form-item label="任务书名称">
                          <el-input :disabled='rwszbForm.disabled' v-model="form.workAssignName"
                                    placeholder="任务书名称"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="审核流程">
                          <el-select :clearable="true" v-model="form.auditProcess" placeholder="请选择审核流程" style="width:100%;"
                                     :disabled='rwszbForm.disabled'
                                     class="xiaLa">
                            <el-option v-for="item in options" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24" v-if="rwszbForm.enter==3||rwszbForm.enter==4 || rwszbForm.enter==6">
                        <el-col :span="6">
                          <el-form-item label="发约人姓名">
                            <el-input v-model="form.fayueName" placeholder="发约人姓名" :disabled='rwszbForm.disabled'
                                      style="width:100%;"></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="6">
                          <el-form-item label="发约人职务">
                            <el-input v-model="form.fayueZhiwu" placeholder="发约人职务" :disabled='rwszbForm.disabled'
                                      style="width: 100%;"></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="6">
                          <el-form-item label="受约人姓名">
                            <el-input v-model="form.shouyueName" placeholder="受约人姓名" :disabled='rwszbForm.disabled'
                                      style="width: 100%;"></el-input>
                          </el-form-item>
                        </el-col>
                        <el-col :span="6">
                          <el-form-item label="受约人职务">
                            <el-input v-model="form.shouyueZhiwu" placeholder="受约人职务" :disabled='rwszbForm.disabled'
                                      style="width: 100%;"></el-input>
                          </el-form-item>
                        </el-col>

                      </el-col>

                      <el-col :span="12">
                        <el-form-item label="任务书有效期">
                          <el-date-picker
                            v-model="form.htYxqq"
                            type="date"
                            :disabled='rwszbForm.disabled'
                            style="width:48%;"
                            placeholder="选择日期">
                          </el-date-picker>
                          <span style="width:4%;display: inline-block;text-align:center">至</span>
                          <el-date-picker
                            v-model="form.htYxqz"
                            style="width:48%;"
                            :disabled='rwszbForm.disabled'
                            type="date"
                            placeholder="选择日期">
                          </el-date-picker>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="签订日期">
                          <el-date-picker
                            v-model="form.signDate"
                            style="width:100%;"
                            :disabled='rwszbForm.disabled'
                            type="date"
                            placeholder="选择日期">
                          </el-date-picker>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="任务书级别">
                          <el-select :clearable="true" v-model="form.signLevel" placeholder="请选择签订级别" style="width:100%;"
                                     :disabled='rwszbForm.disabled'
                                     class="xiaLa">
                            <el-option v-for="item in leveList" :key="item.value" :label="item.name"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6" v-if="rwszbForm.enter==0">
                        <el-form-item label="多人合同模式">
                          <el-select :clearable="true" v-model="form.multiMode" placeholder="请选择多人合同模式" style="width:100%;"
                                     :disabled='rwszbForm.disabled'
                                     class="xiaLa">
                            <el-option v-for="item in modelList" :key="item.value" :label="item.name"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="任务书周期">
                          <el-select :clearable="true" v-model="form.workAssignCycle" placeholder="请选择合同周期" style="width:100%;"
                                     :disabled='rwszbForm.disabled'
                                     class="xiaLa">
                            <el-option v-for="item in periodList" :key="item.value" :label="item.name"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12" v-if="rwszbForm.enter==0">
                        <el-form-item>
                          <!-- <el-button type="primary">选择主管领导</el-button> -->
                          <el-button type="primary"  @click="ndts()">推送拟定</el-button>
                          <el-button type="primary" @click="close">返回</el-button>
                          <el-select :clearable="true" v-model="form.gzZt" placeholder="请选择"
                                     style="width:120px;margin-right:10px;margin-left:10px"
                                     class="xiaLa">
                            <el-option v-for="item in zhiList" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                          <el-button type="primary">复用模板</el-button>
                          <el-button type="primary" @click="addDateHT">保存</el-button>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24" v-if="rwszbForm.enter==0">
                        <el-form-item label="发约人">
                          <template slot="label" v-if="!rwszbForm.disabled">
                            <span>发约人<i style="color: #0482db" class="el-icon-edit-outline cursor-pointer"
                                        @click="addUser('fy')"></i></span>
                          </template>
                          <span class="mg-r15" v-for="item in fayuerendataList">{{ item.fayueName }}</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="24" v-if="rwszbForm.enter==0">
                        <el-form-item label="受约人">
                          <template slot="label" v-if="!rwszbForm.disabled">
                            <span>受约人<i style="color: #0482db" class="el-icon-edit-outline cursor-pointer"
                                        @click="addUser('sy')"></i></span>
                          </template>
                          <span class="mg-r15" v-for="item in shouyuerendataList">{{ item.shouyueName }}</span>
                        </el-form-item>
                      </el-col>
                    </el-form>
                  </el-col>
                </el-row>
                <div style="margin-bottom:20px;">
                  <el-button type="primary" v-if="rwszbForm.enter==1||rwszbForm.enter==2">新增</el-button>
                  <el-button type="primary" v-if="rwszbForm.enter==2||rwszbForm.enter==3||rwszbForm.enter==4 || rwszbForm.enter==6">导出
                  </el-button>
<!--                  <el-button type="primary" v-if="rwszbForm.enter==4">打印</el-button>-->
                  <!-- <el-button type="primary" v-if="rwszbForm.enter==3">打印</el-button> -->
                </div>

              </div>
            </div>
          </div>
        </div>
      </div>
      <!--任务书批量编辑-->
      <div v-if="rwszbForm.enter==5" style="margin-bottom:20px;">
        <el-row>
          <el-col :span="24" style="line-height:30px;">
            添加人员
          </el-col>
          <!--  -->
          <el-col :span="24" style="line-height:30px;">
            <!-- 张文东、刘丽诗、吴姗姗、郭谦、于德刚、岳赫伦、张云鹏 -->
            <span  v-for="item in formAll">{{ item.shouyueName+"," }}</span>

          </el-col>


          <el-col :span="24">
<!--            <el-button type="primary">导入</el-button>-->
<!--            <el-button type="primary">导出</el-button>-->
            <el-button type="primary" @click="bathSave">保存指标</el-button>
            <el-button type="primary" @click="close">关闭窗口</el-button>
          </el-col>
        </el-row>
      </div>
      <!--指标编辑-->
      <div>

<!--        <el-row v-if="rwszbForm.enter==1" class="zhibiaoHead" ref="rwszbForm" >-->
<!--          <el-col :span="24" style="line-height:60px;font-size:24px;border-bottom:1px solid grey"   >-->
<!--              {{form.workAssignName}}-->
<!--          </el-col>-->
<!--          <el-col :span="24" style="border-bottom:1px solid grey">-->
<!--            <el-col :span="8" style="border-right:1px solid grey">-->
<!--              <span>发约人姓名： {{form.fayueName}}</span>-->
<!--            </el-col>-->
<!--            <el-col :span="8" style="border-right:1px solid grey">受约人姓名： {{form.shouyueName}}</el-col>-->
<!--            <el-col :span="8">合同有效期： {{form.htYxqq}}至{{form.htYxqz}}</el-col>-->
<!--          </el-col>-->
<!--          <el-col :span="24">-->
<!--            <el-col :span="8" style="border-right:1px solid grey">职务： {{form.fayueZhiwu}}</el-col>-->
<!--            <el-col :span="8" style="border-right:1px solid grey">职务： {{form.shouyueZhiwu}}</el-col>-->
<!--            <el-col :span="8">签订日期： {{form.signDate}}</el-col>-->
<!--          </el-col>-->
<!--        </el-row>-->
        <div class="table-header-table-box" v-if="rwszbForm.enter==1">
          <table>
            <tbody>
            <tr>
              <td colspan="3" style="height:40px;line-height:40px;font-size:24px">
                {{form.workAssignName}}
              </td>
            </tr>
            <tr>
              <td>
                <div  class="text-left">
                  发约人姓名：{{form.fayueName}}
                </div>
              </td>
              <td>
                <div  class="text-left">
                  受约人姓名：{{form.shouyueName}}
                </div>
              </td>
              <td>合同有效期：{{form.htYxqq}}<span class="mg-0-10">至</span>{{form.htYxqz}}</td>
            </tr>
            <tr>
              <td>
                <div class="flex text-left">
                  <div>职务：</div>
                  <div>
                    <div v-for="item in cutout(form.fayueZhiwu)">{{item}}</div>
                  </div>
                </div>
              </td>
              <td>
                <div class="flex text-left">
                  <div>职务：</div>
                  <div>
                    <div v-for="item in cutout(form.shouyueZhiwu)">{{item}}</div>
                  </div>
                </div>
              </td>
              <td>签订日期：{{form.signDate}}</td>
            </tr>
            </tbody>
          </table>
        </div>
        <div class="table-header-table-box" v-if="rwszbForm.enter==4">
          <table>
            <tbody>
            <tr>
              <td colspan="3" style="height:40px;line-height:40px;font-size:24px">
                任务书名称：{{dataForm.workAssignName}}(得分：{{dataForm.sumZbDf}})
              </td>
            </tr>
            <tr>
              <td>
                <div class="text-left">
                  发约人姓名：{{dataForm.fayueName}}
                </div>
              </td>
              <td>
                <div class="text-left">
                  受约人姓名：{{dataForm.shouyueName}}
                </div>
              </td>
              <td>
                <div class="text-left">
                  任务书有效期：{{dataForm.htYxqq.substring(0,10)}}<span style="margin:0 5px">至</span>{{dataForm.htYxqz.substring(0,10)}}
                </div>
              </td>
            </tr>
            <tr>
              <td>
                <div class="flex text-left">
                  <div>发约人职务：{{dataForm.fayueZhiwu}}</div>
                </div>
              </td>
              <td>
                <div class="flex text-left">
                  <div>受约人职务：{{dataForm.shouyueZhiwu}}</div>
                </div>
              </td>
              <td>
                <div class="text-left">
                  任务书级别:{{dataForm.signLevel}}
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="3">
                <div class="text-left">
                  任务书周期:{{dataForm.workAssignCycle}}
                </div>
              </td>
            </tr>
            </tbody>
          </table>
        </div>
        <div class="mg-10-0">
          <el-radio-group v-model="tabType">
            <el-radio-button label="1">定量</el-radio-button>
            <el-radio-button label="2">定性</el-radio-button>
          </el-radio-group>
          <span class="pull-right">
            <el-button type="primary" @click="addZhiBiaoKu" v-if="rwszbForm.enter==0||rwszbForm.enter==1&&rwszbForm.status==0 ||rwszbForm.enter==5">指标库</el-button>
          </span>
        </div>
        <el-table :data="tableData1" style="width: 100%;" height="60vh" v-if="tabType=='1'">
          <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column>
          <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
           <el-table-column prop="shouyueName" v-if="rwszbForm.enter==2"  label="受约人" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="shouyueZhiwu" v-if="rwszbForm.enter==2"  label="受约人职务" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="zhibiaoType" label="指标类别" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="keyZhibiao" label="关键业绩指标" min-width="120" header-align="center" align="center">
              <template slot-scope="scope"  >
                  <span v-if="show"  >{{scope.row.keyZhibiao}} </span>
                <el-input v-else  v-model="scope.row.keyZhibiao" clearable></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="weight" label="权重(%)" min-width="80" header-align="center" align="center">
             <template slot-scope="scope">
               <span v-if="show"  >{{scope.row.weight}} </span>
                <el-input v-else max="100" min="0" type="number" v-model="scope.row.weight" ></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="unit" label="单位" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="shangnianvalue" label="上年度完成值" min-width="120" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="show"  >{{scope.row.shangnianvalue}} </span>
                <el-input v-else v-model="scope.row.shangnianvalue" clearable></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="increaseDecrease" label="增减幅度" min-width="120" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="show"  >{{scope.row.increaseDecrease}} </span>
                <el-input v-else  v-model="scope.row.increaseDecrease" clearable></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="targetValue" label="目标值" min-width="250" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="show"  >{{scope.row.targetValue}} </span>
                <el-input v-else :rows="1" type="textarea" v-model="scope.row.targetValue"  oninput ="value=value.replace(/[^0-9.]/g,'')" clearable ></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="dataSource" label="数据来源" min-width="120" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="show"  >{{scope.row.dataSource}} </span>
                <el-input v-else  v-model="scope.row.dataSource" clearable></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="completeValue" label="完成值" min-width="80" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="show"  >{{scope.row.completeValue}} </span>
                <el-input v-else  v-model="scope.row.completeValue" clearable></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="dataProvider" label="数据提供部门/人" min-width="120" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.tgLx=='2'">{{scope.row.targetUserName}}</span>
              <span v-else>{{scope.row.dataProvider}}</span>
            </template>

          </el-table-column>
          <el-table-column prop="formulaId" label="公式" min-width="120" header-align="center" align="center">
                <template slot-scope="scope">
                   <el-select v-if="show"  v-model="scope.row.formulaId" placeholder="请选择公式" disabled>
                    <el-option
                      v-for="item in formulaList"
                      :key="item.id"
                      :label="item.gsMc"
                      :value="item.id">
                    </el-option>
                  </el-select>
                  <el-select v-else v-model="scope.row.formulaId" placeholder="请选择公式" filterable>
                    <el-option
                      v-for="item in formulaList"
                      :key="item.id"
                      :label="item.gsMc"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </template>
          </el-table-column>
          <el-table-column prop="seq" label="排序号" min-width="120" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="show"  >{{scope.row.seq}} </span>
                <el-input v-else type="number"  v-model="scope.row.seq" :min="1" :step="1" ></el-input>
              </template>
          </el-table-column>
          <!-- <el-table-column prop="ffzt" v-if="rwszbForm.enter==4" label="完成情况" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="ffzt" v-if="rwszbForm.enter==4" label="得分" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="ffzt" v-if="rwszbForm.enter==4" label="其他奖惩" min-width="120" header-align="center" align="center"></el-table-column> -->
          <!-- <el-table-column header-align="center" label="操作" min-width="200" align="center" v-if="rwszbForm.enter==0||rwszbForm.enter==1||rwszbForm.enter==5">
            <template slot-scope="scope">
              <el-button type="primary" plain>编辑</el-button>
              <el-button type="danger" plain>删除</el-button>
            </template>
          </el-table-column> -->
            <el-table-column header-align="center" align="center" label="操作" v-if="rwszbForm.enter==0||rwszbForm.enter==1 && rwszbForm.status==0  ||rwszbForm.enter==5">
            <!-- <template slot="header" slot-scope="scope">
              <span @click="add1()" style="font-size:30px;cursor: pointer;" class="el-icon-circle-plus"></span>
            </template> -->
            <template slot-scope="scope">
              <span  @click="del1(scope.row,scope.$index)" style="font-size:30px;cursor: pointer;" class="el-icon-remove"></span>
            </template>
          </el-table-column>
          <el-table-column v-if="rwszbForm.enter==2" label="操作" width="220" header-align="center" fixed="right" align="center">
            <template slot-scope="scope">
              <el-button v-if="scope.row.auditStatus == '0'" plain type="primary" @click="ok(scope.row.id)">同意</el-button>
              <el-button v-if="scope.row.auditStatus == '0'" plain type="primary" @click="back(scope.row.id)">驳回</el-button>
            </template>
          </el-table-column>

        </el-table>
        <el-table :data="tableData2" style="width: 100%;" height="60vh" v-if="tabType=='2'">
          <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column>
          <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
          <el-table-column prop="shouyueName" v-if="rwszbForm.enter==2"  label="受约人" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="shouyueZhiwu" v-if="rwszbForm.enter==2"  label="受约人职务" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="zhibiaoType" label="指标类别" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="zhibiaoName" label="指标名称" min-width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="weight" label="权重" min-width="120" header-align="center" align="center"  >
              <template slot-scope="scope" >
                <span v-if="show"  >{{scope.row.weight}} </span>
                <el-input v-else  :max="100" min="0" type="number" oninput="if(value>100)value=100" v-model="scope.row.weight"  ></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="indexContent" label="指标内容" min-width="120" header-align="center" align="center">
              <template slot-scope="scope">
                <span v-if="show"  >{{scope.row.indexContent}} </span>
                <el-input v-else  v-model="scope.row.indexContent"    ></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="unit" label="单位" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="targetValue" label="目标值" min-width="250" header-align="center" align="center">
              <template slot-scope="scope">
                <span v-if="show"  >{{scope.row.targetValue}} </span>
                <el-input v-else type="textarea" :rows="1" v-model="scope.row.targetValue" oninput ="value=value.replace(/[^0-9.]/g,'')" clearable  ></el-input>
              </template>
          </el-table-column>
          <el-table-column prop="dataProvider" label="数据提供部门/人" min-width="120" header-align="center"align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.tgLx=='2'">{{scope.row.targetUserName}}</span>
              <span v-else>{{scope.row.dataProvider}}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="ffzt" v-if="rwszbForm.enter==4" label="完成情况" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="ffzt" v-if="rwszbForm.enter==4" label="得分" min-width="120" header-align="center" align="center"></el-table-column>
          <el-table-column prop="ffzt" v-if="rwszbForm.enter==4" label="其他奖惩" min-width="120" header-align="center" align="center"></el-table-column> -->
          <el-table-column v-if="rwszbForm.enter==0||rwszbForm.enter==1||rwszbForm.enter==5" prop="selfEvalu" label="自评指标"
                           min-width="120" header-align="center" align="center">
            <template slot-scope="scope">
              <el-switch
              v-if="show" disabled
                v-model="scope.row.selfEvalu"
                :active-value="0"
                :inactive-value="1"
                active-color="#13ce66"
                inactive-color="#ff4949">
              </el-switch>
               <el-switch
               v-else
                v-model="scope.row.selfEvalu"
                :active-value="0"
                :inactive-value="1"
                active-color="#13ce66"
                inactive-color="#ff4949">
              </el-switch>
            </template>
          </el-table-column>
              <el-table-column v-if="rwszbForm.enter==0||rwszbForm.enter==1||rwszbForm.enter==5" prop="userId" label="主管领导"
                           min-width="120" header-align="center" align="center">
            <template slot-scope="scope">

              <el-select v-if="show" v-model="scope.row.userId" filterable  placeholder="Select" disabled >
              <el-option-group
                v-for="group in treeData"
                :key="group.deptId"
                :label="group.name"
              >
                <el-option
                  v-for="item in group.sysDeptBeanList"
                  :key="item.userId"
                  :label="item.name"
                  :value="item.userId"
                >
                </el-option>
              </el-option-group>
            </el-select>

              <el-select v-else v-model="scope.row.userId" filterable  placeholder="请选择主管领导" >
              <el-option-group
                v-for="group in treeData"
                :key="group.deptId"
                :label="group.name"
              >
                <el-option
                  v-for="item in group.sysDeptBeanList"
                  :key="item.userId"
                  :label="item.name"
                  :value="item.userId"
                >
                </el-option>
              </el-option-group>
            </el-select>
            </template>
          </el-table-column>
          <el-table-column header-align="center" align="center" label="操作" v-if="rwszbForm.enter==0||rwszbForm.enter==1&&rwszbForm.status==0 ||rwszbForm.enter==5">
            <!-- <template slot="header" slot-scope="scope">
              <span @click="add2()" style="font-size:30px;cursor: pointer;" class="el-icon-circle-plus"></span>
            </template> -->
            <template slot-scope="scope">
              <span  @click="del2(scope.row,scope.$index)" style="font-size:30px;cursor: pointer;" class="el-icon-remove"></span>
            </template>
          </el-table-column>
          <el-table-column v-if="rwszbForm.enter==2" label="操作" width="220" fixed="right" header-align="center" align="center">
            <template slot-scope="scope">
              <el-button v-if="scope.row.auditStatus == '0'" plain type="primary" @click="ok(scope.row.id)">同意</el-button>
              <el-button v-if="scope.row.auditStatus == '0'" plain type="primary" @click="back(scope.row.id)">驳回</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-col :span="24" style="text-align:center;margin-top:20px;" v-if="rwszbForm.enter==1 || rwszbForm.enter==0 || rwszbForm.enter==2">
          <el-button v-if="rwszbForm.status==0" type="primary" @click="saveWorkZb">确认保存</el-button>
          <el-button type="primary" @click="close">关闭窗口</el-button>
        </el-col>
        <el-col :span="24" v-if="rwszbForm.enter==0">
          <p><b>任务书创建时指标添加属性 是否自评-再发起时取消 自评选择（自评发送给数据提供部门， 数据提供部门-数据提供部门领导审批）</b></p>
          <p><b>如果自评指标维护了主管领导自评后发送给主管领导审批，</b></p>
          <p><b>如果非自评指标维护了主管领导第二步发送到主管领导。</b></p>
          <p style="color:#ff3300"><b>1、自评指标 维护主管领导，流程：自评→主管领导</b></p>
          <p style="color:#ff3300"><b>2、自评指标 未维护主管领导，流程：自评→数据提供部门</b></p>
          <p style="color:#ff3300"><b>3、非自评指标 维护主管领导，流程：数据提供部门→主管领导</b></p>
          <p style="color:#ff3300"><b>4、非自评指标 未维护主管领导，流程：数据提供部门→数据提供部门领导审批</b></p>
        </el-col>
        <el-col :span="24" style="line-height:40px;border:1px solid #ebeef5;border-top:none;" v-if="rwszbForm.enter==3 || rwszbForm.enter==6" >
          <el-col :span="12" style="border-right:1px solid #ebeef5;"><span style="margin-left:20px;">发约人签名：陈洋</span>
          </el-col>
          <el-col :span="12"><span style="margin-left:20px;">受约人签名：张晓飞</span></el-col>
        </el-col>
        <el-col :span="24" style="text-align:center;margin-top:20px;" v-if="rwszbForm.enter==3||rwszbForm.enter==4 ||rwszbForm.enter==6">
          <el-button type="primary" @click="close">上一个</el-button>
          <el-button v-if="rwszbForm.enter==3 || rwszbForm.enter==6" type="primary" @click="wbshok()" >同意</el-button>
          <el-button v-if="rwszbForm.enter==3 || rwszbForm.enter==6" type="primary" @click="wbshback()" >驳回</el-button>
          <el-button v-if="rwszbForm.enter==4" type="primary" @click="close">返回</el-button>
          <el-button type="primary" @click="close">下一个</el-button>
        </el-col>
      </div>
    </basic-container>
    <!--  选择人员信息-->
    <UserCommonSelect v-if="usercomment" ref="usercomment" @submitfy="submitfy"></UserCommonSelect>
    <!--  添加指标库-->
    <RWSZBTable  ref="renwushuzhibiao" @selectedZhiBiao="selectedZhiBiao"></RWSZBTable>
         <!--    发送指标部门-->
    <el-dialog title="请选择指标拟定部门" :close-on-click-modal="false" :visible.sync="zbvisible" append-to-body>
      <div style="height: 50vh">
        <el-row>
          <el-col :span="8">
            <div class="text-center">
              <el-tree
                :data="treeOrgData"
                show-checkbox
                node-key="id"
                :default-expanded-keys="[2, 3]"
                :default-checked-keys="[5]"
                :props="defaultProps"
                @check-change="handleCheckChange">
              </el-tree>
            </div>
          </el-col>
         <!-- <el-col :span="4">
            <div class="text-center" style="line-height: 50vh">
              <el-button type="primary" @click="fnConfirmSelectedData">选择机构<i class="el-icon-d-arrow-right el-icon&#45;&#45;right"></i></el-button>
            </div>
          </el-col>-->
          <!--<el-col :span="10">
            <div class="text-center">
              <el-table
                :data="confirmTreeData"
                border>
                <el-table-column
                  prop="label"
                  header-align="center"
                  align="center"
                  label="机构名称">
                </el-table-column>
                <el-table-column
                  header-align="center"
                  align="center"
                  label="操作">
                  <template slot-scope="scope">
                    <el-button type="danger" plain size="small">删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-col>-->
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        
      <el-button type="primary" @click="ts()">推送</el-button>
      <el-button type="primary" plain @click="zbvisible = false">返回</el-button>
    </span>

    </el-dialog>
  </div>
</template>

<script>
import UserCommonSelect from '@/views/hetongrenwu/components/usercomment-select'
import RWSZBTable from '@/views/hetongrenwu/components/renwushuzhibiao-table'
import { getWorkAssignzbList,saveWorkZb,removeById,getFormula ,bathSave } from '@/api/hetongrenwu/gongzuorenwushu/workAssignzb'
import {saveHtong,getNiDingList,renwundts,getZhuguanTree,wbshok,wbshback} from '@/api/hetongrenwu/gongzuorenwushu/workAssigncj'
import {ok, back} from '@/api/hetongrenwu/gongzuorenwushu/workAssignzb'


export default {
  name: "renwushuzb-form",
  props: {
    rwszbForm: {
      disabled: false
    }
  },
  components: {
    UserCommonSelect,
    RWSZBTable
  },

     data() {
    return {
      form: {
        userName: ""
      },
      options: [
        {label:'2021年全员绩效考核通用流程',value:'1'},
        {label:'2021年第一季度技术合同流程',value:'2'}
      ],
      leveList:[
        {name:'所属单位部门负责人',value:'1'},
        {name:'本部一般管理人员',value:'2'},
        {name:'所属单位一般管理人员',value:'3'}
      ],
      modelList: [
        {name:'多人共享成绩',value:'0'},
        {name:'生成多个合同',value:'1'}
      ],
      periodList: [
        {name:'月度',value:'1'},
        {name:'季度',value:'2'},
        {name:'年度',value:'3'}
      ],
      zhiList: [
        {value: "模板导出", label: "模板导出"},
        {value: "模板导入", label: "模板导入"},
      ],
      tableData1: [
        {}
      ],
      tableData2:[],
      usercomment: false,
      searchadvanced: true,
      searchheight: '0',
      fayuerendataList: [],
      shouyuerendataList: [],
      tabType:'2',
      formulaList:[],
      selectedTreeData:[],
      zbvisible:false,
      treeOrgData:[],
      treeData:[],
      confirmTreeData:[
        {
          id: 5,
          label: '二级机构'
        }
      ],
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      show:false,
      dataForm: {},
      formAll:[]

    }
  },
  watch:{
    tabType(value){
      this.getDataList(value);
      this.zhuguanTree(value);

    }
  },
  created() {
    this.getTreeData()



  },
  methods: {
    ndts(){
      var workAssignAuditStatus=this.form.workAssignAuditStatus;
      if(workAssignAuditStatus==0){
        this.zbvisible=true;
      }
    },
       //拟定推送-里面
    ts(){
      var id=this.form.id;

      if(this.selectedTreeData.length==0){
        this.$message.error("拟定部门不能为空！");
        return false;
      }
      var ids=this.selectedTreeData.map(item=>{
        return item.deptId;
      })
      var idsStr=ids.join(',')
      this.$confirm('是否要拟定推送？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function () {
        return renwundts({id:id,ndDeptId:idsStr})
      }).then(data => {
        this.$message.closeAll();
        this.$message.success('拟定推送成功')
        this.zbvisible=false;
        // this.getDataList()
      })
    },
    //获取树结构
    getTreeData(){
      getNiDingList().then(res=>{
        this.treeOrgData=res.data.data
      })
    },
      //树结构选中的数据
    handleCheckChange(data){
      var index =this.selectedTreeData.findIndex(item =>item.deptId==data.deptId)
      if(index==-1){
        this.selectedTreeData.push(data)
      }else{
        this.selectedTreeData.splice(index,1)
      }
    },
     //确定选择选中得机构
    fnConfirmSelectedData(){
      this.confirmTreeData=this.selectedTreeData
    },
      getFormula(value){
          getFormula().then(response => {
            if(value==1){
            this.formulaList = response.data.data;
            }
          })
      },
      // 获取数据列表
      getDataList(value) {
        this.dataListLoading = true
        var htid=null
        var id =null;
        if(this.rwszbForm.enter==1){
          htid=this.form.htId
        }
        if(this.rwszbForm.enter==0){
          htid=this.form.id
        }
        if(this.rwszbForm.enter==2){
          id=this.form.id
        }
        if(this.rwszbForm.enter==3|| this.rwszbForm.enter==6){
          htid=this.form.id
        }
        if(this.rwszbForm.enter==4){
          htid=this.dataForm.id
        }


        getWorkAssignzbList(Object.assign({
          htId:htid,
          dingType:value,
          enter:this.rwszbForm.enter,
          id:id

        })).then(response => {
          if(value==1){
          this.getFormula(value);
          this.tableData1 = response.data.data;
          }
          if(value==2){
          this.tableData2 = response.data.data;
          }
          // this.$nextTick(function(){
          //   this.dataListLoading = false
          // })
        })

      },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = 'auto'
      }
    },
    //增加人员
    addUser(type) {
      this.usercomment = true;
      // if(type='fy'){
      //   this.jsonData=this.dataForm.fayuejson;
      // }else{
      //   this.jsonData=this.dataForm.shouyuejson;
      // }
      this.$nextTick(() => {
        this.$refs.usercomment.init('12', type, this.jsonData);
      });
    },
    //确定选择的人员
    submitfy(data) {
      if (data.type == 'fy') {
        this.fayuerendataList = data.tableDataUser;
      } else if (data.type == 'sy') {
        this.shouyuerendataList = data.tableDataUser;
      }
    },
    //添加一行数据
    add1(){
      this.tableData1.push({})
    },
    //删除一行数据
    del1(row,index){
        if(row.id ==undefined || row.id == null){
          this.tableData1.splice(index, 1);
        }else{
              removeById(row.id).then(res=>{
                if(res.data.code==0){
                  this.$message.closeAll();
                  this.$message.success("删除成功！")
                }else{
                  this.$message.success("删除失败！")
                }
                  this.getDataList(this.tabType);

              })

          this.tableData1.splice(index, 1);
        }

    },
    //添加一行数据
    add2(){
      this.tableData2.push({})
    },
    //删除一行数据
    del2(row,index){
      if(row.id ==undefined || row.id == null){
          this.tableData2.splice(index, 1);
        }else{
              removeById(row.id).then(res=>{
                 if(res.data.code==0){
                  this.$message.closeAll();
                  this.$message.success("删除成功！")
                }else{
                  this.$message.closeAll();
                  this.$message.success("删除失败！")
                }
                this.getDataList(this.tabType)
              })
          this.tableData2.splice(index, 1);
        }
    },
    //添加指标库
    addZhiBiaoKu(){
      //alert(this.tabType)
      // if(this.tabType=='1'){
      //   //定量
      // }else if(this.tabType=='2'){
      //   //定性
      // }
      var data={
        dialogVisible:true,
        tabType:this.tabType
      }
      this.$nextTick(() => {
        this.$refs.renwushuzhibiao.init(data)
      })
    },
    //确定选择的任务书指标
    selectedZhiBiao(data){
       var tab1={},tab2={};
       var table1=[];
       var table2=[];
      if(this.tabType=='1'){
         for(var i=0;i<data.length;i++){
            tab1 = Object.assign({}, tab1, {
              id:undefined,
              zhibiaoType: data[i].normLx,
              unit: data[i].normDw,
              zhibiaoName: data[i].normName,
              })
            table1.push(tab1);
          }
        this.tableData1=this.tableData1.concat(table1);
      }else if(this.tabType=='2'){
        for(var i=0;i<data.length;i++){
            tab2 = Object.assign({}, tab2, {
              id:undefined,
              zhibiaoType: data[i].normLx,
              unit: data[i].normDw,
              zhibiaoName: data[i].normName,
              })
            table2.push(tab2);
          }
        this.tableData2=this.tableData2.concat(table2)
      };
    },
    close() {
      this.$emit('zhibiaoChild', '关闭')
    },
    initAll(data){

      this.formAll=data
      this.zhuguanTree(this.tabType);
    },
    init(data) {
      if(data.enter==0||data.enter==3|| data.enter==6){
        this.$nextTick(() => {
          this.$refs['rwszbForm'].resetFields()
        })
      }
      if(data.enter==2||data.enter==3 || data.enter==6){
        this.show=true;
      }
      if(data.status==1 ){
        this.show=true;

      }
      if(data.enter==4){
        this.dataForm = data;
        this.show=true;
      }


      if(data != undefined){
        this.form=data;
        this.fayuerendataList=[];
        this.shouyuerendataList=[];
        this.isbtnHidden = true;
        this.$forceUpdate();
        var list1=[],list2=[],obj={},list3=[],list4=[],obj2={};
        if(this.rwszbForm.enter!=2){


          if(data.fayueZhiwu.split(',')&&data.fayueZhiwu.split(',')){
            list1=data.fayueName.split(',')
            list2=data.fayueZhiwu.split(',');
            for(var i in list1){
              obj={
                fayueName:list1[i],
                fayueZhiwu:list2[i]
              }
              this.fayuerendataList.push(obj);
            }
          }else{
            obj={
              fayueName:data.fayueName,
              fayueZhiwu:data.fayueZhiwu
            }
            this.fayuerendataList.push(obj)
          }
          if(data.shouyueName.split(',')&&data.shouyueZhiwu.split(',')){
            list3=data.shouyueName.split(',')
            list4=data.shouyueZhiwu.split(',');
            for(var i=0;i<list3.length;i++){
              obj2={
                shouyueName:list3[i],
                shouyueZhiwu:list4[i]
              }
              this.shouyuerendataList.push(obj2);
            }
          }else{
            obj2={
              shouyueName:data.shouyueName,
              shouyueZhiwu:data.shouyueZhiwu
            }
            this.shouyuerendataList.push(obj2)
          }
        }
      }
      // this.dataForm.id = JSON.stringify(data.id) || 0;
      this.visible = true;
      this.canSubmit = true;
      this.getDataList(this.tabType);
      this.zhuguanTree(this.tabType);

    },
    addDateHT() {
      this.form.fayuejson=JSON.stringify(this.fayuerendataList);
      this.form.shouyuejson=JSON.stringify(this.shouyuerendataList);
      saveHtong(this.form).then(res=>{
        this.$message.closeAll();
        this.$message.success('保存成功')
        this.visible=false;
        this.$emit("refreash",'1')
      })
    },
    saveWorkZb() {
       var htid=null
        if(this.rwszbForm.enter==1){
          htid=this.form.htId
        }
        if(this.rwszbForm.enter==0){
          htid=this.form.id
        }
      if(this.tabType==1){
         saveWorkZb({
           htId:htid,
           dingType:this.tabType,
           workAssignzbsList:this.tableData1
         }).then(res=>{
            if(res.data.code==0){
              this.$message.closeAll();
              this.$message.success(res.data.msg)
            }else{
              this.$message.closeAll();
              this.$message.success(res.data.msg)
            }
            this.getDataList(this.tabType)
      })

      }
      if(this.tabType==2){
         saveWorkZb({
           htId:htid,
           dingType:this.tabType,
           workAssignzbsList:this.tableData2
         }).then(res=>{
            if(res.data.code==0){
              this.$message.closeAll();
              this.$message.success(res.data.msg)
            }else{
              this.$message.closeAll();
              this.$message.success(res.data.msg)
            }
            this.getDataList(this.tabType)
      })

      }

    },
    bathSave(){
      var tableData=[];
      if(this.tabType==1){
        tableData=this.tableData1
      }
      if(this.tabType==2){
        tableData=this.tableData2

      }

      bathSave({
           dingType:this.tabType,
           workAssignzbsList:tableData,
           workAssignzbndList:this.formAll
         }).then(res=>{
            if(res.data.code==0){
              this.$message.closeAll();
              this.$message.success(res.data.msg)
            }else{
              this.$message.closeAll();
              this.$message.success(res.data.msg)
            }
            this.$emit('zhibiaoChild', '关闭')
            this.getDataList(this.tabType)
      })


    },

    //拆分字段
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if(c.size<1){
          c.push('-');
          c.push('-');
        } else if(c.size<2){
          c.push('-');
        }
        return c;
      }
    },
    zhuguanTree(value) {
      if(value==2){
        getZhuguanTree(this.listQuery).then(response => {
          this.treeData = response.data.data
        })
      }


    },
      wbshok(){
      this.$confirm('是否要通过该指标?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        wbshok({
             id:this.form.id,
          enter:this.form.enter
        }).then(res => {
          this.$message.closeAll();
          this.$message({
            type: 'success',
            message: '提交成功!'
          });
                this.$emit('zhibiaoChild', '关闭')

        }).catch(() => {
          this.$message({
            type: 'error',
            message: '提交失败!'
          });
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消提交'
        });
      });
    },
    wbshback(){
      this.$confirm('是否要驳回该指标?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        wbshback({
          id:this.form.id,
          enter:this.form.enter
        }).then(res => {
          this.$message.closeAll();
          this.$message({
            type: 'success',
            message: '提交成功!'
          });
                this.$emit('zhibiaoChild', '关闭')

        }).catch(() => {
          this.$message({
            type: 'error',
            message: '提交失败!'
          });
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消提交'
        });
      });
    },


     ok(id){
            this.$confirm('是否要通过该指标?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                ok(id).then(res => {
                    this.$message.closeAll();
                    this.$message({
                        type: 'success',
                        message: '提交成功!'
                    });
                  this.getDataList(this.tabType)
                }).catch(() => {
                    this.$message({
                        type: 'error',
                        message: '提交失败!'
                    });
                  this.getDataList(this.tabType)
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消提交'
                });
            });
      },
      back(id){
            this.$confirm('是否要驳回该指标?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                back(id).then(res => {
                    this.$message.closeAll();
                    this.$message({
                        type: 'success',
                        message: '驳回成功!'
                    });
                  this.getDataList(this.tabType)
                }).catch(() => {
                    this.$message({
                        type: 'error',
                        message: '提交失败!'
                    });
                  this.getDataList(this.tabType)
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消提交'
                });
            });
        },



  }

}
</script>

<style>
.zhibiaoHead {
  border: 1px solid grey;
  text-align: center;
  line-height: 30px;
}
</style>
